import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as actions from "../store/action"
import { bindActionCreators } from 'redux'
export class Title extends Component {
  render() {
    console.log(this.props,"tab退")
    let {list, activeIndex,activeAction}=this.props
    return (
      

      <div>
          <p>111</p>
          
          
          {
        list.length  ? list.map((item,index)=>{
            return <button 
            className={index===activeIndex ?'on' :''}
            key={item.id}
            onClick={()=>[
                activeAction(index)
            ]}
            >{item.name}</button>
        }):'暂无数据'
          
          
          }</div>
    )
  }
}

const mapStateToProps = (state) => ({
    ...state.reducer
})

const mapDispatchToProps = (dispatch)=>{
     return bindActionCreators(actions,dispatch)
}
   


export default connect(mapStateToProps, mapDispatchToProps)(Title)